Skip to main content

libobs_simple\sources\linux\sources/
x11_capture.rs

1use libobs_wrapper::{data::StringEnum, sources::ObsSourceRef};
2
3use crate::sources::macro_helper::{define_object_manager, impl_default_builder};
4
5#[derive(Clone, Copy, Debug, PartialEq, Eq)]
6/// Describes the X11 capture server type
7pub enum ObsX11ServerType {
8    /// Local X11 server
9    Local,
10    /// Custom X11 server
11    Custom,
12}
13
14impl StringEnum for ObsX11ServerType {
15    fn to_str(&self) -> &str {
16        match self {
17            ObsX11ServerType::Local => "local",
18            ObsX11ServerType::Custom => "custom",
19        }
20    }
21}
22
23define_object_manager!(
24    #[derive(Debug)]
25    /// A source to capture X11 screen/window content.
26    ///
27    /// This source provides screen capture functionality on Linux systems running X11.
28    /// It can capture the entire screen or specific areas with cropping options.
29    struct X11CaptureSource("xshm_input", *mut libobs::obs_source) for ObsSourceRef {
30        /// Screen/Display to capture
31        #[obs_property(type_t = "int")]
32        screen: i64,
33
34        /// Whether to show the cursor in the capture
35        #[obs_property(type_t = "bool")]
36        show_cursor: bool,
37
38        /// Enable advanced settings
39        #[obs_property(type_t = "bool")]
40        advanced: bool,
41
42        /// X Server to connect to (when using advanced settings)
43        #[obs_property(type_t = "string")]
44        server: String,
45
46        /// Crop from top (in pixels)
47        #[obs_property(type_t = "int")]
48        cut_top: i64,
49
50        /// Crop from left (in pixels)
51        #[obs_property(type_t = "int")]
52        cut_left: i64,
53
54        /// Crop from right (in pixels)
55        #[obs_property(type_t = "int")]
56        cut_right: i64,
57
58        /// Crop from bottom (in pixels)
59        #[obs_property(type_t = "int")]
60        cut_bot: i64,
61    }
62);
63
64impl_default_builder!(X11CaptureSourceBuilder);